package g4p.tests;


import processing.core.PApplet;

public class EventTest_01 extends PApplet {

	String[] pme = new String[] {"PRESS", "RELEASE", "CLICK", "DRAG", "MOVE", "ENTER", "EXIT" };
	String[] jme = new String[] {"MOUSE_CLICKED", "MOUSE_PRESSED", "MOUSE_RELEASED", "MOUSE_MOVED", "MOUSE_ENTERED", "MOUSE_EXITED", "MOUSE_DRAGGED" };
	int last_jme, last_pme;
	
	public void setup(){
		size(200,200);
		cursor(CROSS);
		registerMethod("mouseEvent", this);
	}

	public void mouseEvent(processing.event.MouseEvent e) {
		int me = e.getAction();
		if(me != last_pme){
			System.out.println("P_ME >> " + getMouseAction(me));
			last_pme = me;
		}
	}


	public void mouseEvent(java.awt.event.MouseEvent e){
		int me = e.getID();
		if(me != last_jme){
			System.out.println("J_ME >> " + getMouseAction(me));
			last_jme = me;
		}
	}
	
	
	public void draw(){
		background(240);
	}
	
	public String getMouseAction(int action){
		if(action >= 1 && action <= 7)
			return pme[action - 1];
		if(action >= 500 && action <= 506)
			return jme[action - 500];
		return ("Mouse action error with " + action);
	}
}
